473,473 Members | 2,196 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Dbase / foxpro files

Is there a module for reading/modifing db files from Python?
Thanks for help
B.
Jun 27 '08 #1
10 4746
Johny wrote:
Is there a module for reading/modifing db files from Python?
There is a recipe by Raymond Hettinger:

http://aspn.activestate.com/ASPN/Coo.../Recipe/362715

Peter
Jun 27 '08 #2
Johny wrote:
Is there a module for reading/modifing db files from Python?
Thanks for help
B.
I have a module -- which I'm going to get around to releasing one of
these days :-) -- which allows to read dBase III, dBase IV and Foxpro
files (sequentially only, not randomly) and to write dBaseIII files
sequentially. Index files if any are ignored.

Field types supported for reading:
C character
D date
F float
I integer (32 bits)
L logical
M memo (stored in a .DBT (dBase) or .FPT (FoxPro) file)
N number
T time

Writing supports only dBaseIII with C, D, L and N fields, but could be
extended easily enough (I've never had the need). No index files are
written.

E-mail me if you are interested.

Cheers,
John
Jun 27 '08 #3
On May 15, 5:21*pm, John Machin <sjmac...@lexicon.netwrote:
Johny wrote:
Is there a module for reading/modifing db files from Python?
Thanks for help
B.

I have a module -- which I'm going to get around to releasing one of
these days :-) -- which allows to read dBase III, dBase IV and Foxpro
files (sequentially only, not randomly) and to write dBaseIII files
sequentially. Index files if any are ignored.

Field types supported for reading:
C character
D date
F float
I integer (32 bits)
L logical
M memo (stored in a .DBT (dBase) or .FPT (FoxPro) file)
N number
T time

Writing supports only dBaseIII with C, D, L and N fields, but could be
extended easily enough (I've never had the need). No index files are
written.

E-mail me if you are interested.

Cheers,
John
Hello John,
Yes, I am interested. Is it possible to download the module?
Thanks
Lad
Jun 27 '08 #4
Johny ha scritto:
Is there a module for reading/modifing db files from Python?
Thanks for help
B.
If your target is Windows, you can try mediator components

http://www.otc.pl/download/

which are COM objects based on xHarbour and which give you
full access to DBF and index.

You need PythonWin too.

I did some tests, if you like i can send you something,
call me in my private mail.

Claudio
Jun 27 '08 #5
Johny wrote:
Is there a module for reading/modifing db files from Python?
Thanks for help
B.
Just create a ODBC DataSource (Control Panel/Administrative Tools/
DataSources) and use ODBC to read/write.

-Larry
Jun 27 '08 #6
ma*************@gmail.com wrote:
look at

http://pypi.python.org/pypi?%3Aactio...&submit=search

i use dbfpy
That's another option. The caveat is that dbfpy specifically states that it
only works on "simple" files. I'm pretty sure ODBC is universal.

The nice thing about using ODBC is that:

1) Nothing to install, every Windows machine has ODBC
2) If you upgrade to some other ODBC compliant database you have little or no
changes that are required to your application.

Just my 2 cents.

-Larry
Jun 27 '08 #8
Johny wrote:
>Is there a module for reading/modifing db files from Python?
Thanks for help
B.
--
http://mail.python.org/mailman/listinfo/python-list

I'm switching my company's software base over from FoxPro 6 to Python.
As part of that effort I have written (and am still enhancing :) a
dbf.py module which reads/writes both dBase III and FoxPro tables.

Index files are not supported, but the table can be sorted by any
combination of fields after being opened.

dBase III table/memo support is complete, but FoxPro field types
Currency, Double, General, and Picture are not supported and those
fields are stripped out when opened, and will not be in any saved
version of that table. At this point, the dbf file itself is read into
memory, all updates are held in memory, and the table is only written to
disk when the Save method is called.

Record navigation can be sequential or random, and Top, Bottom, Next,
and Previous are supported.

Searching is supported, using (or not) deleted records is supported,
adding and deleting fields is supported, saving as a csv file, and more.

Let me know if you'd like the module. Hope this helps.

Sample session follows...
>>import dbf
table = dbf.DbfTable('newtable','name C(10), age N(3.0), wisdom M')
print table
Table: newtable.dbf
Type: dBase III Plus
Last updated: 2008-05-16
Record count: 0
Field count: 3
Record length: 24

--Fields--
name C(10)
age N(3.0)
wisdom M(10)
>>table.Append()
table.name = 'Ethan'
table.age = 37
table.wisdom = 'Python rules!'
table.Scatter()
{'age': 37, 'name': 'Ethan', 'wisdom': 'Python rules!'}
>>table.GetField('name')
'Ethan'
>>table[0]
Ethan 37 1
>>record = table[0]
record.name
'Ethan'
>>record.wisdom
'Python rules!'
>>record.age = 40
record
Ethan 40 1
>>table[0]
Ethan 40 1
>>table.Append({'name':'Lori', 'age':45, 'wisdom':'happy gardens make
a happy wife'})
>>table.Scatter()
{'age': 45, 'name': 'Lori', 'wisdom': 'happy gardens make a happy wife'}
>>for record in table:
.... print record.name, record.wisdom
....
Ethan Python rules!
Lori happy gardens make a happy wife
>>>

Jun 27 '08 #9
Thanks for your reply.Is it possible to delete a record by using the
module?
Thanks
L>
Jun 27 '08 #10
Johny wrote:
>Thanks for your reply.Is it possible to delete a record by using the
module?
Thanks
L>
--
http://mail.python.org/mailman/listinfo/python-list

It is possible with mine. To clarify an earlier post, my module is for
dBase III and VFP 6.0 files only (those were the only two I needed :).

Hope this helps.
--
Ethan

Jun 27 '08 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Matt Young | last post by:
I've been tasked with integrating an older management system based on DBF files with my snappy new ASP application to provide users of the ASP application with real-time data from the management...
2
by: Kshitij | last post by:
HI, How to connect to the dBase database?? One option is to create a DSN and use it.But I want to do it in some other way like just passing a connection string or like that. Thanks in advance.
2
by: NOSPAMrclark | last post by:
I am looking for information on how to deal with dbase index files (cdx) when modifying data in dbase database files (dbf). I have an application with hundreds of .dbf files that I need to modify...
1
by: Derek Griffiths | last post by:
Most of the complicated programs I write are boring applications that manipulate databases associated with the medical billing program where I work. The program uses foxpro dbases (version 3) for...
2
by: trint | last post by:
Anyone aware of c#, ado.Net dbase IV code sample? I would like to just open and view a .dbf table. Thanks, Trint
6
by: coriolis_wong | last post by:
Hi, I need to transfer csv format file to DBase III format file. How do i do it in Python language? Any help is appreciated. Thanks.
0
by: JeffP | last post by:
Error at Open() - Driver does not support this function I've tried the OLEdb driver with similar failure, different error but basically I cannot Open using the Foxpro driver(s) Any clues? ...
2
by: Songyang | last post by:
I'm new to this group. In my company in Japan, we have been using dbase for almost 20 years, and we are now switching to foxpro. Dose anybody here has experience in converting dbase programs from...
4
by: Robert Bravery | last post by:
HI all, Can someone show me or point me to a place where I can find out how to update dbase(dbf) tables. Thanks RObert
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.